// SAX for Pascal, Registration for SAX Packages.
// http://sourceforge.net/projects/saxforpascal/
// Based on http://www.saxproject.org/
// No warranty; no copyright -- use this as you will.
unit SAXReg;

interface

{$I SAX.inc}

uses
  Classes, SAXComps, SAX,
{$IFDEF DELPHI6_UP}
  DesignIntf, DesignEditors;
{$ELSE}
  DsgnIntf;
{$ENDIF}

procedure Register;

implementation

{$R *.dcr}

type

  TSAXVendorPropEditor = class(TStringProperty)
  public
    function GetAttributes: TPropertyAttributes; override;
    procedure GetValues(Proc: TGetStrProc); override;
    procedure SetValue(const Value: string); override;
  end;

  procedure Register;
  begin
    RegisterComponents('SAX', [ TSAXXMLReader,
                                TSAXDocumentWriter,
                                TSAXContentHandler,
                                TSAXDeclHandler,
                                TSAXDTDHandler,
                                TSAXEntityResolver,
                                TSAXErrorHandler,
                                TSAXLexicalHandler,
                                TSAXContentWriter,
                                TSAXDeclWriter,
                                TSAXDTDWriter,
                                TSAXLexicalWriter,
                                TSAXFilter,
                                TSAXSplitter
                               ]);

    RegisterPropertyEditor(TypeInfo(string), TSAXCustomXMLReader, 'Vendor',
      TSAXVendorPropEditor);
  end;

{ TSAXVendorPropEditor }

function TSAXVendorPropEditor.GetAttributes: TPropertyAttributes;
begin
  Result := [paValueList];
end;


procedure TSAXVendorPropEditor.GetValues(Proc: TGetStrProc);
var
  I: Integer;
  Values : TStringList;
begin
  Values := TStringList.Create;
  try
    ListSAXVendors(Values);
    for I:= 0 to Values.Count-1 do    // Iterate
      Proc(values.Strings[I]);
  finally
    values.Free;
  end;
end;


procedure TSAXVendorPropEditor.SetValue(const Value: string);
begin
  SetStrValue(Value);
end;

end.
